import 'dart:math';

import 'package:flutter_map/flutter_map.dart';
import 'package:latlong/latlong.dart';
import 'package:map_elevation/map_elevation.dart';
import 'package:flutter/material.dart';

///@className data_util
///@author liaoyu
///@version 1.0.0
///@description 数据生成
///@createTime 2021/1/7 10:15

class DataUtil {
  static List<ElevationPoint> getPoints() {
    List<List<double>> data = [
      [104.054591, 30.561392, 0.0],
      [104.056093, 30.561115, 0.0],
      [104.05693, 30.56093, 0.0],
      [104.057531, 30.560819, 0.0],
      [104.05811, 30.560357, 0.0],
      [104.059376, 30.559969, 0.0],
      [104.05884, 30.559674, 0.0],
      [104.059849, 30.559193, 0.0],
      [104.05987, 30.558824, 0.0],
      [104.059827, 30.55851, 0.0],
      [104.059441, 30.557826, 0.0],
      [104.059763, 30.557438, 0.0],
      [104.059988, 30.557309, 0.0],
      [104.060192, 30.556958, 0.0],
      [104.059988, 30.55681, 0.0],
      [104.059881, 30.556339, 0.0],
      [104.059752, 30.556172, 0.0],
      [104.059452, 30.556089, 0.0],
      [104.05914, 30.556034, 0.0],
      [104.059022, 30.556126, 0.0],
      [104.058733, 30.556117, 0.0],
      [104.058475, 30.556228, 0.0],
      [104.05752, 30.556283, 0.0],
      [104.057102, 30.556477, 0.0],
      [104.056952, 30.556653, 0.0],
      [104.056641, 30.556616, 0.0],
      [104.05649, 30.55657, 0.0],
      [104.056287, 30.556607, 0.0],
      [104.055385, 30.556865, 0.0],
      [104.054956, 30.557142, 0.0],
      [104.054988, 30.557401, 0.0],
      [104.054903, 30.557817, 0.0],
      [104.054634, 30.558205, 0.0],
      [104.053669, 30.558861, 0.0],
      [104.053851, 30.558427, 0.0],
      [104.052993, 30.55899, 0.0],
      [104.052531, 30.558916, 0.0],
      [104.05177, 30.559249, 0.0],
      [104.051587, 30.559341, 0.0],
      [104.051512, 30.559923, 0.0],
      [104.05162, 30.560256, 0.0],
      [104.050933, 30.560302, 0.0],
      [104.051426, 30.560718, 0.0],
      [104.051523, 30.561392, 0.0],
      [104.052102, 30.561568, 0.0],
      [104.053175, 30.561549, 0.0]
    ];
    for (int i = 0; i < data.length; i++) {
      Random random = new Random();
      int rLatOffset = random.nextInt(100) + 1; // 1-100之间区间
      data[i][2] = rLatOffset * 10.0;
    }
    if (data != null) {
      return data.map((e) => ElevationPoint(e[1], e[0], e[2])).toList();
    }
    return [];
  }

  static List<LatLng> getLatLngs() {
    List<List<double>> data = [
      [104.054591, 30.561392, 0.0],
      [104.056093, 30.561115, 0.0],
      [104.05693, 30.56093, 0.0],
      [104.057531, 30.560819, 0.0],
      [104.05811, 30.560357, 0.0],
      [104.059376, 30.559969, 0.0],
      [104.05884, 30.559674, 0.0],
      [104.059849, 30.559193, 0.0],
      [104.05987, 30.558824, 0.0],
      [104.059827, 30.55851, 0.0],
      [104.059441, 30.557826, 0.0],
      [104.059763, 30.557438, 0.0],
      [104.059988, 30.557309, 0.0],
      [104.060192, 30.556958, 0.0],
      [104.059988, 30.55681, 0.0],
      [104.059881, 30.556339, 0.0],
      [104.059752, 30.556172, 0.0],
      [104.059452, 30.556089, 0.0],
      [104.05914, 30.556034, 0.0],
      [104.059022, 30.556126, 0.0],
      [104.058733, 30.556117, 0.0],
      [104.058475, 30.556228, 0.0],
      [104.05752, 30.556283, 0.0],
      [104.057102, 30.556477, 0.0],
      [104.056952, 30.556653, 0.0],
      [104.056641, 30.556616, 0.0],
      [104.05649, 30.55657, 0.0],
      [104.056287, 30.556607, 0.0],
      [104.055385, 30.556865, 0.0],
      [104.054956, 30.557142, 0.0],
      [104.054988, 30.557401, 0.0],
      [104.054903, 30.557817, 0.0],
      [104.054634, 30.558205, 0.0],
      [104.053669, 30.558861, 0.0],
      [104.053851, 30.558427, 0.0],
      [104.052993, 30.55899, 0.0],
      [104.052531, 30.558916, 0.0],
      [104.05177, 30.559249, 0.0],
      [104.051587, 30.559341, 0.0],
      [104.051512, 30.559923, 0.0],
      [104.05162, 30.560256, 0.0],
      [104.050933, 30.560302, 0.0],
      [104.051426, 30.560718, 0.0],
      [104.051523, 30.561392, 0.0],
      [104.052102, 30.561568, 0.0],
      [104.053175, 30.561549, 0.0]
    ];
    return data.map((e) => LatLng(e[1], e[0])).toList();
  }

  static List<Polyline> getPolylines() {
    List<List<double>> data = [
      [104.054591,30.561392],
      [104.056093,30.561115],
      [104.05693,30.56093],
      [104.057531,30.560819],
      [104.05811,30.560357],
      [104.059376,30.559969],
      [104.05884,30.559674],
      [104.059849,30.559193],
      [104.05987,30.558824],
      [104.059827,30.55851],
      [104.059441,30.557826],
      [104.059763,30.557438],
      [104.059988,30.557309],
      [104.060192,30.556958],
      [104.059988,30.55681],
      [104.059881,30.556339],
      [104.059752,30.556172],
      [104.059452,30.556089],
      [104.05914,30.556034],
      [104.059022,30.556126],
      [104.058733,30.556117],
      [104.058475,30.556228],
      [104.05752,30.556283],
      [104.057102,30.556477],
      [104.056952,30.556653],
      [104.056641,30.556616],
      [104.05649,30.55657],
      [104.056287,30.556607],
      [104.055385,30.556865],
      [104.054956,30.557142],
      [104.054988,30.557401],
      [104.054903,30.557817],
      [104.054634,30.558205],
      [104.053669,30.558861],
      [104.053851,30.558427],
      [104.052993,30.55899],
      [104.052531,30.558916],
      [104.05177,30.559249],
      [104.051587,30.559341],
      [104.051512,30.559923],
      [104.05162,30.560256],
      [104.050933,30.560302],
      [104.051426,30.560718],
      [104.051523,30.561392],
      [104.052102,30.561568],
      [104.053175,30.561549]
    ];
    List<Polyline> polylines = [];
    for (int i = 0; i < data.length - 1; i++) {
      List<double> first = data[i];
      List<double> second = data[i + 1];
      polylines.add(Polyline(points: [LatLng(first[1], first[0]), LatLng(second[1], second[0])], color: Colors.red, strokeWidth: 3.0));
    }
    polylines.add(Polyline(points: [LatLng(data[data.length - 1][1], data[data.length - 1][0]), LatLng(data[0][1], data[0][0])], color: Colors.red, strokeWidth: 3.0));
    polylines.add(Polyline(points: [LatLng(data[data.length - 1][1], data[data.length - 1][0]), LatLng(data[0][1], data[0][0])], color: Colors.red, strokeWidth: 3.0));
    return polylines;
//    return data.map((e) => Polyline(points: [LatLng(e[1],e[0])],color: Colors.red,strokeWidth:3.0)).toList();
  }

  static List<LatLng> getMarkersLatLng() {
    List<List<double>> data = [
      [104.05693, 30.559655, 0.0],
      [104.056211, 30.558778, 0.0],
      [104.061436, 30.559471, 0.0],
      [104.055804, 30.559886, 0.0]
    ];

    return data.map((e) => LatLng(e[1], e[0])).toList();
  }
}
